<?php 
class PartnersBlock extends CWidget {
 
	/*
    public function init()    {     
    }
    */	
	
    public function run() {
    	$partners = ProjectPartners::model()->findAll('hidden = 0');
    	$img_dir = Yii::app()->params->partner_images_path;
        $this->render('partnersBlock',array('partners' => $partners, 'img_dir' => $img_dir));
    }
	
	protected function getImgSrc($name, $path_part, $mode = 'thumb',$useDefault = true) {
		$web_path = Yii::app()->getBaseUrl(true);
		$real_path = Yii::getPathOfAlias('webroot');
		$src = $web_path.'/images/noimage-100.png';
		if ('' == $name) return $src;
		$tmp_src = '';
	    switch($mode) {
    		case 'thumb':
    		default:
    			$tmp_src = $path_part.Yii::app()->params->image_thumb_key.$name;
    		break;
    		case 'image':
    			$tmp_src = $path_part.'img_'.$name;
    		break;	
    		case 'orig':
    			$tmp_src = $path_part.$name;
    		break;
    	}
    	if ('' == $tmp_src) {
    		return ($useDefault) ? $src : '';	
    	}
    	if (!file_exists($real_path.$tmp_src)) {
    		return ($useDefault) ? $src : '';	
    	}
		return $web_path.$tmp_src;
	}    
    
}


?>